//
//  ViewController.m
//  whfdemo003
//
//  Created by 王洪飞 on 2024/6/13.
//

#import "ViewController.h"
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
#import "Render.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

@interface ViewController ()
@property (nonatomic, strong) EAGLContext *mContext;
@property (nonatomic, strong) Render *render;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
    GLKView *view = (GLKView *)self.view;
    view.context = self.mContext;
    [EAGLContext setCurrentContext:self.mContext];
  
    // Do any additional setup after loading the view.
}

-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect{
    if (self.render == nil) {
        self.render = [[Render alloc] initWithWidth:view.drawableWidth andHeight:view.drawableHeight];
    }
    glClearColor(1, 1, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    [self.render draw];
}

@end
